# -*- encoding: utf-8 -*-
'''
Filename         :3_lengthOfLongestSubstring.py
Description      :
Time             :2022/08/02 10:15:50
Author           :daiyizheng
Email            :387942239@qq.com
Version          :1.0
'''

class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        st = {}
        i, ans = -1, 0
        for j in range(len(s)):
            if s[j] in st:
                i = max(st[s[j]], i)
            ans = max(ans, j - i)
            st[s[j]] = j
        return ans;
            